package com.example.harmonyosdemo.base;

import ohos.aafwk.ability.Ability;
import ohos.aafwk.content.Intent;
import ohos.aafwk.content.Operation;

public class BaseAbility extends Ability {
    public static String TAG = "BaseAbility";


    @Override
    protected void onStart(Intent intent) {
        super.onStart(intent);
        TAG = getClass().getSimpleName();
    }


    public void openActivity(Class<? extends Ability> clazz) {
        Intent intent = new Intent();
        Operation operation = new Intent.OperationBuilder()
                //.withAction(Intent.ACTION_QUERY_WEATHER)
                .withDeviceId("") // 跳转到那个设备上，如果传递一个没有内容的字符串，表示跳转本机
                .withBundleName("com.example.harmonyosdemo")
                .withAbilityName(clazz.getName())
                .build();
        intent.setOperation(operation);
        startAbility(intent);
    }

    public void openActivity(Class<? extends Ability> clazz, Intent intent) {
        Operation operation = new Intent.OperationBuilder()
                //.withAction(Intent.ACTION_QUERY_WEATHER)
                .withDeviceId("") // 跳转到那个设备上，如果传递一个没有内容的字符串，表示跳转本机
                .withBundleName("com.example.harmonyosdemo")
                .withAbilityName(clazz.getName())
                .build();
        intent.setOperation(operation);
        startAbility(intent);
    }

    public void openActivity(Class<? extends Ability> clazz, int requestCode) {
        Intent intent = new Intent();
        Operation operation = new Intent.OperationBuilder()
                //.withAction(Intent.ACTION_QUERY_WEATHER)
                .withDeviceId("") // 跳转到那个设备上，如果传递一个没有内容的字符串，表示跳转本机
                .withBundleName("com.example.harmonyosdemo")
                .withAbilityName(clazz.getName())
                .build();
        intent.setOperation(operation);
        startAbilityForResult(intent, requestCode);
    }

    public void openActivity(Class<? extends Ability> clazz, Intent intent, int requestCode) {
        Operation operation = new Intent.OperationBuilder()
                //.withAction(Intent.ACTION_QUERY_WEATHER)
                .withDeviceId("") // 跳转到那个设备上，如果传递一个没有内容的字符串，表示跳转本机
                .withBundleName("com.example.harmonyosdemo")
                .withAbilityName(clazz.getName())
                .build();
        intent.setOperation(operation);
        startAbilityForResult(intent, requestCode);
    }


}
